package com.ngmaster.socket;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;

/**
 * Tcp服务器的频道
 *
 */
public class TcpChannel extends ChannelInitializer<SocketChannel> {

	/**
	 * Tcp服务器的逻辑
	 */
	private ITcpLogic tcpServerLogic = null;
	
	/**
	 * 构造函数
	 * @param logic
	 */
	public TcpChannel(ITcpLogic logic) {
		tcpServerLogic = logic;
	}
	
	@Override
	protected void initChannel(SocketChannel arg0) throws Exception {
		arg0.pipeline().addLast(new MessageFrameDecoder(10240));
		arg0.pipeline().addLast(new TcpHandler(tcpServerLogic));
	}
}
